package com.app.mp3player;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.RelativeLayout;

public class MainActivity extends Activity {

	private static final String TAG = "MainActivity";

	public static final int LOCAL = 1;
	public static final int REMOTE = 2;
	
	private RelativeLayout localMusic;
	private RelativeLayout remoteMusic;
	private Intent intent;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.main);
		localMusic = (RelativeLayout)findViewById(R.id.local_music_item);
		remoteMusic = (RelativeLayout)findViewById(R.id.remote_music_item);
		
		//设置跳转信息
		intent = new Intent();
		intent.setClass(this, Mp3ListActivity.class);
		
		//绑定事件
		localMusic.setOnClickListener(new LocalMusicOnClickListener());
		remoteMusic.setOnClickListener(new remoteMusicOnClickListener());
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		getMenuInflater().inflate(R.menu.main, menu);
		return true;
	}
	
	
	/**
	 * 点击本地歌曲
	 * @author yinhuadong
	 *
	 */
	class LocalMusicOnClickListener implements OnClickListener{

		@Override
		public void onClick(View v) {
			intent.putExtra("type", LOCAL);
			startActivity(intent);
		}
		
	}
	
	/**
	 * 点击远程歌曲
	 * @author yinhuadong
	 *
	 */
	class remoteMusicOnClickListener implements OnClickListener{

		@Override
		public void onClick(View v) {
			intent.putExtra("type", REMOTE);
			startActivity(intent);
		}
		
	}

}
